package com.ccp.dev.qbdms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ccp.dev.core.basic.annotion.Action;
import com.ccp.dev.core.basic.api.ISysOrg;
import com.ccp.dev.core.basic.consts.UrlConstants;
import com.ccp.dev.core.basic.internationalization.SysBaseController;
import com.ccp.dev.core.basic.response.ResultData;
import com.ccp.dev.core.basic.util.ContextUtil;
import com.ccp.dev.core.basic.util.PropertyUtil;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.poi.excel.reader.TableEntity;
import com.ccp.dev.core.util.RequestUtil;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.core.util.log.SysAuditThreadLocalHolder;
import com.ccp.dev.extend.service.ExtendSysOrgService;
import com.ccp.dev.extend.service.ExtendSysUserService;
import com.ccp.dev.form.service.impl.ScriptImpl;
import com.ccp.dev.qbdms.consts.ZhiLiangConst;
import com.ccp.dev.qbdms.expimp.CustomExcelReader;
import com.ccp.dev.qbdms.expimp.util.AbstractExpUtil;
import com.ccp.dev.qbdms.expimp.util.AbstractImpUtil;
import com.ccp.dev.qbdms.expimp.util.AuxiliaryUtil;
import com.ccp.dev.qbdms.model.WQbdTecAchievements;
import com.ccp.dev.qbdms.model.WQbdTecBasicmanage;
import com.ccp.dev.qbdms.model.WQbdTecFundsplans;
import com.ccp.dev.qbdms.service.*;
import com.ccp.dev.qbdms.util.BaseUtil;
import com.ccp.dev.qbdms.util.ProjectUUIDUtils;
import com.ccp.dev.qbdms.util.StructureModifyUtil;
import com.ccp.dev.system.model.SysOrg;
import com.ccp.dev.system.model.SysUser;
import com.ccp.dev.system.service.SysOrgService;
import com.ccp.dev.system.service.SysUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * 课题 信息操作处理控制器
 *
 * @author zhl
 * @date 2020-05-25 15:16:53
 */
@Controller
/**
 * 请将此名称添加到日志开关
 */
@Action(customModel = "课题信息")
@RequestMapping("/qbdms/wQbdTecBasicmanage")
public class WQbdTecBasicmanageController extends SysBaseController {
    @Resource
    private WQbdTecBasicmanageService wQbdTecBasicmanageService;
    @Resource
    private WQbdTecFundsplansService wQbdTecFundsplansService;
    @Resource
    private WQbdTecAchievementsService wQbdTecAchievementsService;
    @Resource
    private SysUserService sysUserService;
    @Resource
    private WQbdFalSuperviseService wQbdFalSuperviseService;
    @Resource
    private ScriptImpl scriptImpl;
    @Resource
    private SysOrgService sysOrgService;
    @Resource
    private ExtendSysOrgService extendSysOrgService;
    @Resource
    private WCustomColumnsService wCustomColumnsService;
    @Resource
    private ExtendSysUserService extendSysUserService;

    /**
     * 功能描述: 跳转到首页
     *
     * @return: java.lang.String
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_LIST)
    @Action(description = "跳转到课题首页", exectype = "页面跳转日志")
    public String viewList(ModelMap modelMap, HttpServletRequest request) {

        wCustomColumnsService.addCustomCols(request);
        modelMap.put("originOrgList", JSON.toJSONString(extendSysOrgService.getOriginOrgToDicList()));
        BaseUtil.SystemLevel currentSystemLevel = BaseUtil.getCurrentSystemLevel();
        // 返回当前系统等级
        modelMap.put("currentSystemLevel", currentSystemLevel);

        // 返回当前登录人
        modelMap.put("userId", ContextUtil.getCurrentUserId());

        // 只能看到下级单位,以及当前单位
        ISysOrg currentOrg = ContextUtil.getCurrentOrg();
        HashMap<String, String> hashMap = new HashMap<>(16);
        List<Map> org;
        if (BaseUtil.SystemLevel.GROUPLEVEL.equals(currentSystemLevel)) {
            // 集团看所有
            // 传一个空的map,需要参数的时候直接放入hashMap
            org = wQbdFalSuperviseService.getOrg2(hashMap);
        } else {
            // 二级，三级单位看本单位以及全部三级单位
            hashMap.put("ORGSUPID", currentOrg.getOrgId());
            hashMap.put("ISTENANT", "1");
            hashMap.put("this", "this");
            org = wQbdFalSuperviseService.getOrg(hashMap);
        }

        modelMap.put("org", JSON.toJSONString(org));
        return "wQbdTecBasicmanage/list";
    }

    /**
     * 功能描述: 附带检索条件的分页查询
     *
     * @param: [request] http请求
     * @return: java.lang.Object
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_LIST)
    @ResponseBody
    @Action(description = "附带检索条件的分页查询课题", detail = "查询数据信息<#if success>成功<#else></#if>")
    public Object list(HttpServletRequest request) throws IllegalAccessException {
        QueryFilter queryFilter = new QueryFilter(request, true);
        // 创建时间倒序排序
        queryFilter.addFilter("orderField", "CREATETIME");
        queryFilter.addFilter("orderSeq", "desc");
        ZhiLiangConst.addQueryFilter(queryFilter);
        //分页数据
        List<WQbdTecBasicmanage> pageDatas = wQbdTecBasicmanageService.queryList(queryFilter);
        // 密级、上报状态、数据来源单位显示中文
        ZhiLiangConst.showName(pageDatas);
        // 添加编辑按钮权限控制
        ZhiLiangConst.isDataAllowEdit(pageDatas, true);
        SysAuditThreadLocalHolder.putParamerter("success", true);
        return success(pageDatas, queryFilter.getPageBean().getTotalCount());
    }


    /**
     * 功能描述: 跳转到新增页面
     *
     * @return: java.lang.String
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + UrlConstants.MODULE_FUNCTION_ADD_UPDATE)
    @Action(description = "跳转到课题新增页面", exectype = "页面跳转日志")
    public String viewAdd(HttpServletRequest request, ModelMap modelMap) {
        String id = RequestUtil.getString(request, "id");
        modelMap.put("id", id);
        String userId = ContextUtil.getCurrentUserId();
        QueryFilter queryFilter = new QueryFilter(request);
        SysOrg tenOrg1 = extendSysOrgService.getTenOrg(userId);
        queryFilter.addFilter("orgId",tenOrg1.getOrgId());
        // 查询当前单位下的 所有人，包括下级单位与部门的人
        List<SysUser> sysUsers = sysUserService.list(queryFilter);
        // 查询当前部门下的人
//        List<SysUser> sysUsers = sysUserService.queryUserListByOrgId(ContextUtil.getCurrentOrgId());
        ArrayList<Map> zrrList = new ArrayList<>();
        for (SysUser user : sysUsers) {
            Map<String, String> map = new HashMap<>();
            map.put(user.getUserId(), user.getFullName());
            zrrList.add(map);
        }
        modelMap.put("dwzrr", JSON.toJSONString(zrrList));

        // 只能看到下级单位,以及当前单位
        SysOrg tenOrg = extendSysOrgService.getTenOrg(userId);
        // 主承单位名称
        modelMap.put("zcdw", tenOrg.getOrgName());
        // 主承单位ID
        modelMap.put("zcdwId", tenOrg.getCode());
        // 组织验收部门
        String tenantId = ContextUtil.getCurrentUserTenantId();
        List<SysOrg> sysOrgList = extendSysOrgService.getOrgsByTenId(tenantId);
        sysOrgList.removeIf(sysOrg -> sysOrg.getIsTenant() == 1);
        modelMap.put("checkdepts", JSON.toJSONString(sysOrgList));

        String fileManagementUploadType = PropertyUtil.getByAlias("fileManagementUploadType", "");
        modelMap.put("fileManagementUploadType", fileManagementUploadType);
        String wjszsdsxlx = PropertyUtil.getByAlias("wjszsdsxlx", "");
        modelMap.put("wjszsdsxlx", wjszsdsxlx);
        modelMap.put("currentUserId", scriptImpl.getCurrentUserId());

        return "wQbdTecBasicmanage/add";
    }

    /**
     * 功能描述:  数据保存通用方法
     *
     * @param: wQbdTecBasicmanage 保存的对象
     * @return: java.lang.Object
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_SAVE)
    @ResponseBody
    @Action(description = "保存课题数据", detail = "<#if isAdd>新增<#else>编辑</#if>课题数据<#if success>成功<#else>失败</#if><#if StringUtil.isNotEmpty(modifyInfo)>${modifyInfo}</#if>")
    public Object save(@RequestBody WQbdTecBasicmanage wQbdTecBasicmanage) {
        String id = wQbdTecBasicmanage.getId();
        int result;
        if (StringUtil.isEmpty(id)) {
            SysAuditThreadLocalHolder.putParamerter("isAdd", true);
            //新增操作
            //新增数据前生成随机Id
            wQbdTecBasicmanage.setId(ProjectUUIDUtils.getUUIDFor32());
            ZhiLiangConst.addCommonFields(wQbdTecBasicmanage);
            //上报状态
            BaseUtil.SystemLevel currentSystemLevel = BaseUtil.getCurrentSystemLevel();
            if (BaseUtil.SystemLevel.GROUPLEVEL.equals(currentSystemLevel)) {
                wQbdTecBasicmanage.setReportStatus(ZhiLiangConst.getDataInitStatusToHospital());
            } else if (BaseUtil.SystemLevel.HOSPITALLEVEL.equals(currentSystemLevel)) {
                wQbdTecBasicmanage.setReportStatus(ZhiLiangConst.getDataInitStatusToGroup());
            } else if (BaseUtil.SystemLevel.PLANTLEVEL.equals(currentSystemLevel)) {
                wQbdTecBasicmanage.setReportStatus(ZhiLiangConst.getDataInitStatusToHospital());
            }
            result = wQbdTecBasicmanageService.add(wQbdTecBasicmanage);
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
            WQbdTecBasicmanage old = wQbdTecBasicmanageService.getOneById(id);
            String modifyInfo = StructureModifyUtil.getModifyInfo(old, wQbdTecBasicmanage);
            SysAuditThreadLocalHolder.putParamerter("modifyInfo", modifyInfo);
            ZhiLiangConst.updateCommonFields(wQbdTecBasicmanage);
            //修改操作
            result = wQbdTecBasicmanageService.update(wQbdTecBasicmanage);
        }
        if (result > 0) {
            SysAuditThreadLocalHolder.putParamerter("success", true);
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
        }
        return result > 0 ? getResultDataSuccess("save.success") : getResultDataError("save.failure");
    }

    /**
     * 功能描述: 跳转到详情页面
     *
     * @return: java.lang.String
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/particulars")
    @Action(description = "跳转到课题详情页面", exectype = "页面跳转日志")
    public String viewParticulars(HttpServletRequest request, ModelMap modelMap) {
        String id = RequestUtil.getString(request, "id");
        modelMap.put("id", id);
        String isClose = RequestUtil.getString(request, "isClose");
        modelMap.put("isClose", isClose);
        return "wQbdTecBasicmanage/particulars";
    }

    /**
     * 功能描述: 根据主键id获取一条数据的通用查询方法
     *
     * @param: id 参数对象必须是"id"
     * @return: java.lang.Object
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping(UrlConstants.MODULE_FUNCTION_GET)
    @ResponseBody
    @Action(description = "根据主键id查询课题的一条数据", detail = "根据主键id查询课题的数据<#if success>成功<#else>失败</#if>")
    public Object get(@RequestParam("id") String id, HttpServletRequest request) {
        String mark = RequestUtil.getString(request, "mark");
        WQbdTecBasicmanage wQbdTecBasicmanage = wQbdTecBasicmanageService.getOneById(id);
        List<WQbdTecFundsplans> listByRefId = wQbdTecFundsplansService.getListByRefId(id);
        List<WQbdTecAchievements> listByRefId2 = wQbdTecAchievementsService.getListByRefId(id);
        wQbdTecBasicmanage.setwQbdTecFundsplans(listByRefId);
        wQbdTecBasicmanage.setwQbdTecAchievements(listByRefId2);

/*        if (StringUtil.isNotEmpty(mark)) {
            if (wQbdTecBasicmanage.getfCheckdept() != null) {
                SysOrg sysOrg = sysOrgService.getSysOrgByOrgCode(wQbdTecBasicmanage.getfCheckdept());
                // 组织验收部门
                wQbdTecBasicmanage.setfCheckdept(sysOrg.getOrgName() == null ? "" : sysOrg.getOrgName());
            }
        }*/
//        List<WQbdCalRewandpuns> wQbdCalRewandpunsList = wQbdCalRewandpunsService.getListByRefId(wQbdFalProblemreset.getId());
//        wQbdFalProblemreset.setwQbdCalRewandpuns(wQbdCalRewandpunsList);

/*        // 填报信息中的填报组织
        if (StringUtil.isNotEmpty(wQbdTecBasicmanage.getFilldeptid())) {
            wQbdTecBasicmanage.setFilldept(sysOrgService.getSysOrgByOrgCode(wQbdTecBasicmanage.getFilldeptid()).getOrgName());
        }
        // 填报信息中的填报人
        if (StringUtil.isNotEmpty(wQbdTecBasicmanage.getFillmanaccount())) {
            wQbdTecBasicmanage.setFillman(sysUserService.getByAccount(wQbdTecBasicmanage.getFillmanaccount()).getFullName());
        }

        // 填报信息中的填报人 fMainunit
        if (StringUtil.isNotEmpty(wQbdTecBasicmanage.getfMainunitid())) {
            wQbdTecBasicmanage.setfMainunit(sysOrgService.getSysOrgByOrgCode(wQbdTecBasicmanage.getfMainunitid()).getOrgName());
        }*/


        if (null == wQbdTecBasicmanage) {
            SysAuditThreadLocalHolder.putParamerter("success", false);
            return getResultDataError("get.failure");
        }
        SysAuditThreadLocalHolder.putParamerter("success", true);
        return getResultDataSuccess("get.success", wQbdTecBasicmanage);
    }

    /**
     * 功能描述: 根据主键ID删除数据的通用删除方法
     *
     * @param: id 参数名称必须是"id"
     * @return: java.lang.Object
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @PostMapping(UrlConstants.MODULE_FUNCTION_DELETE)
    @ResponseBody
    @Action(description = "根据主键ID删除课题数据", exectype = "删除日志", detail = "删除数据信息<#if success>成功<#else>失败</#if>")
    public Object delete(@RequestParam("id") String id) {

        String userId = ContextUtil.getCurrentUserId();
        String[] ids = id.split(",");
        for (String key : ids) {
            WQbdTecBasicmanage wQbdTecTopicreview = wQbdTecBasicmanageService.getOneById(key);
            if (Objects.nonNull(wQbdTecTopicreview.getReportStatus()) && !ZhiLiangConst.REPORT_STATUS_GROUPTOBEREPORTED.equals(wQbdTecTopicreview.getReportStatus()) && !ZhiLiangConst.REPORT_STATUS_TEMP_TOBEREPORTED.equals(wQbdTecTopicreview.getReportStatus())) {
                SysAuditThreadLocalHolder.putParamerter("success", false);
                return fail("删除失败，只允许删除待上报和待报集团的数据");
            }
            if (!userId.equals(wQbdTecTopicreview.getCreateBy())) {
                SysAuditThreadLocalHolder.putParamerter("success", false);
                return fail("删除失败，只能删除自己创建的数据！");
            }
        }

        if (StringUtil.isEmpty(id)) {
            SysAuditThreadLocalHolder.putParamerter("success", false);
            return fail("delete.failure.message");
        }
        int result = wQbdTecBasicmanageService.delByIdArray(id.split(","));
        if (result > 0) {
            SysAuditThreadLocalHolder.putParamerter("success", true);
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
        }
        return result > 0 ? getResultDataSuccess("delete.success") : getResultDataError("delete.failure");
    }

    /**
     * 功能描述: 跳转到导入页面
     *
     * @return: java.lang.String
     * @auther: hw
     * @date: 2019-12-25 19:21:40
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/import")
    @Action(description = "跳转到课题导入页面", exectype = "页面跳转日志")
    public String viewImport() {
        return "wQbdTecBasicmanage/import";
    }


    /**
     * 功能描述: 跳转到导出选择字段页面
     *
     * @return: java.lang.String
     * @auther: hw
     * @date: 2019-12-25 19:21:40
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/export")
    @Action(description = "跳转到质量问题导出选择字段页面", exectype = "页面跳转日志")
    public String export(HttpServletRequest request, ModelMap modelMap) throws Exception {
        com.alibaba.fastjson.JSONObject jsonObject = AuxiliaryUtil.resolverModel(WQbdTecBasicmanage.class);
        modelMap.put("tableInfo", jsonObject.toString());
        return "expImp/add";
    }

    /**
     * 功能描述: 导出课题数据信息
     *
     * @param: [request] http请求
     * @return: java.lang.Object
     * @auther: zhl
     * @date: 2020-05-25 15:16:53
     */
    @RequestMapping("/exportData")
    @Action(description = "导出课题数据信息", detail = "导出课题数据信息<#if success>成功<#else></#if>")
    public void exportData(HttpServletRequest request, HttpServletResponse response) throws Exception {
        SysAuditThreadLocalHolder.putParamerter("success", false);
        String[] id = RequestUtil.getStringAryByStr(request, "id");
        QueryFilter queryFilter = new QueryFilter(request, false);
        // 默认按照创建时间倒序排列
        if (StringUtil.isEmpty(queryFilter.get("orderField"))) {
            queryFilter.addFilter("orderField", "CREATETIME");
            queryFilter.addFilter("orderSeq", "desc");
        }
        JSONArray dataArray = ZhiLiangConst.exportAddConditions(queryFilter, id);
        List<WQbdTecBasicmanage> wQbdTecBasicmanages = this.wQbdTecBasicmanageService.queryAll(queryFilter);
        if (wQbdTecBasicmanages.isEmpty()) {
            wQbdTecBasicmanages.add(new WQbdTecBasicmanage());
        }
        new AbstractExpUtil() {
            @Override
            public String customAnalysis(String fieldName, String fieldValue) {
                return null;
            }
        }.executeExport(request, response, wQbdTecBasicmanages, dataArray, AbstractExpUtil.ExpStyle.MANY_SHEET);
        SysAuditThreadLocalHolder.putParamerter("success", true);
    }

    /**
     * 导入资源文件
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @RequestMapping("/importData")
    @ResponseBody
    @Action(description = "导入课题数据信息", detail = "导入课题数据信息<#if success>成功<#else></#if>")
    public ResultData importData(MultipartHttpServletRequest request, HttpServletResponse response) throws Exception {
        SysAuditThreadLocalHolder.putParamerter("success", false);
        MultipartFile multipartFile = request.getFile("file");
        TableEntity excelEntity = new CustomExcelReader().readFile(multipartFile.getInputStream());

        // 已验收项目成果信息填报（“是否完成验收”字段选择为“是”时，展示下面的数据项，要求为必填项）
        // 需要校验的字段 整数数字类型
        String[] strNum = new String[]{"fRecommendationpages", "fKeytechnology", "fPrototype", "fSample", "fSamplenum", "fEquipment", "fDemosystem", "fDatabase", "fTechnicalstandard", "fProcessspecification", "fApplicationpatent", "fAuthorizedpatent", "fTrademark",
                "fSoftware", "fCopyright", "fPaper", "fMonograph", "fGraduatestudent", "fModelproducts", "fReports"};
        String[] strMoney = new String[]{"fApprovalmoney", "fNationalmoney", "fRaisemoney", "fFunds", "fOtherfunds", "fArrangedfinancialfun", "fArrangedotherfunds"};
        ArrayList<String> nums = new ArrayList<>();
        ArrayList<String> moneys = new ArrayList<>();
        Collections.addAll(nums, strNum);
        Collections.addAll(moneys, strMoney);
        ArrayList<String> peoples = new ArrayList<>();
        peoples.add("fDeptchargeperson");
        peoples.add("fTopicchargeperson");
        ArrayList<String> strPeople = new ArrayList<>();
        strPeople.add("fDeptchargepersonid");
        strPeople.add("fTopicchargepersonid");

        Map<String, Object> map = new AbstractImpUtil() {
            @Override
            public ReturnType customValidation(String fieldName, String fieldValue) {

                ReturnType returnType = null;
                if ("fMainunitid".equals(fieldName)) {
                    returnType = new ReturnType();
                    List<SysOrg> sysOrgs = sysOrgService.queryByOrgName(fieldValue);
                    if (sysOrgs.size() > 0) {
                        SysOrg sysOrg = sysOrgs.get(0);
                        if (StringUtil.isNotEmpty(sysOrg.getCode())) {
                            returnType.setNewValue(sysOrg.getCode());
                        } else {
                            returnType.setNewValue("");
                        }
                    } else {
                        returnType.setMsg("当前系统没有所填单位！");
                    }
                }

                if ("fTechnology".equals(fieldName)) {
                    returnType = new ReturnType();
                    List<SysOrg> sysOrgs = sysOrgService.queryByOrgName(fieldValue);
                    if (sysOrgs.size() > 0) {
                        SysOrg sysOrg = sysOrgs.get(0);
                        if (StringUtil.isNotEmpty(sysOrg.getCode())) {
                            returnType.setNewValue(sysOrg.getCode());
                        } else {
                            returnType.setNewValue("");
                        }
                    } else {
                        returnType.setMsg("当前系统没有所填部门！");
                    }
                }

                if ("fItemstartdate".equals(fieldName)) {
                    returnType = new ReturnType();
                    String val = fieldValue.replaceAll(" ", "");
                    String[] split = val.split("-");
                    if (split.length == 2) {
                        if (split[0].matches("^[1-9]+[0-9]*$") && split[1].matches("^[1-9]+[0-9]*$") && split[0].length() == 4 && split[1].length() == 4) {
                            returnType.setNewValue(val.replaceAll("-", " - "));
                        } else {
                            returnType.setMsg("日期范围格式错误请重新填写");
                        }
                    } else {
                        returnType.setMsg("日期范围格式错误请重新填写");
                    }
                }

                if (peoples.contains(fieldName)) {
                    returnType = new ReturnType();
                    List<SysUser> byFullname = extendSysUserService.getByFullname(fieldValue);
                    if (byFullname.size() == 0) {
                        returnType.setMsg("当前系统没有所填人员！");
                    } else {
                        returnType.setNewValue(fieldValue);
                    }
                }

                if (nums.contains(fieldName)) {
                    returnType = new ReturnType();
                    boolean matches = fieldValue.matches("^[1-9]+[0-9]*$");
                    if (!matches) {
                        returnType.setMsg("只能输入非负整数！");
                    } else {
                        returnType.setNewValue(fieldValue);
                    }
                }

                if(strPeople.contains(fieldName)){
                    returnType = new ReturnType();
                    List<SysUser> sysUsers = extendSysUserService.getByFullname(fieldValue);
                    if (sysUsers.size() > 0) {
                        SysUser sysUser = sysUsers.get(0);
                        if (StringUtil.isNotEmpty(sysUser.getUserId())) {
                            returnType.setNewValue(sysUser.getUserId());
                        } else {
                            returnType.setMsg("不存在的人员！");
                        }
                    } else {
                        returnType.setMsg("不存在的人员！");
                    }
                }

                if (moneys.contains(fieldName)) {
                    returnType = new ReturnType();
                    // 校验金额
                    boolean matches = fieldValue.matches("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$");
                    if (!matches) {
                        returnType.setMsg("请输入数字且小数最多两位！");
                    } else {
                        returnType.setNewValue(fieldValue);
                    }
                }
                return returnType;
            }
        }.reverseModels(excelEntity, WQbdTecBasicmanage.class);
        String msg = map.get("msg").toString();
        List<WQbdTecBasicmanage> list = (List<WQbdTecBasicmanage>) map.get("instList");
        if (StringUtil.isEmpty(msg)) {
            this.wQbdTecBasicmanageService.addImportData(list);
            SysAuditThreadLocalHolder.putParamerter("success", true);
            return getResultDataSuccess("dataSource.importXml.success");
        } else {
            SysAuditThreadLocalHolder.putParamerter("success", false);
            return fail(msg);
        }

    }

    /**
     * 评审会列表页面
     */
    @RequestMapping(UrlConstants.VIEW_DISPATCH_PREFIX + "/review")
    @Action(description = "打开已关联课题评审会列表页面", exectype = "页面跳转日志")
    public String track(HttpServletRequest request, ModelMap modelMap) {
        String did = RequestUtil.getString(request, "did");
        modelMap.put("did", did);
        return "wQbdTecBasicmanage/review";
    }


//    //
//    @RequestMapping("/getPersonnel")
//    @ResponseBody
//    public String getXhdh(HttpServletRequest request, HttpServletResponse response) {
//        String f_xhdh = request.getParameter("f_xhdh");
//        String id = request.getParameter("id");
//        System.out.println(id);
//        return "exist";
//    }

    /**
     * 查询上报的信息
     *
     * @param request
     * @param id
     * @param tableName
     * @return
     */
    @RequestMapping("/reportList")
    @ResponseBody
    public Object reportList(HttpServletRequest request, @RequestParam("id") String id, @RequestParam("tableName") String tableName) {
        //业务数据
        List<WQbdTecBasicmanage> reportList = wQbdTecBasicmanageService.reportList(id, tableName);
        SysAuditThreadLocalHolder.putParamerter("success", true);
        return getResultDataSuccess("options.success", reportList);
    }


}
